#include <stdio.h>
int main(int argc,char *argv[])
{
	int x;
	long long int n;
	scanf("%d %d",&x,&n);
	long long int a;
	int b;
	a = x + n;
	b = a % 7;
	long long int sum;
	sum = n + a + 7 - b;
	long long int meter;
	meter = (sum / 7)*5*250;
	if(x <= 5)
	{
		meter = meter - (x-1)*250;
	}
	else
	{
		meter = meter;
	}
	if(b <= 5)
	{
		meter = meter - (5-b)*250;
	}
	else
	{
		meter = meter;
	}
	printf("%lld\n",meter-1250);
	return 0;
} 
